const path = require('path');
function resolve(dir) {
  return path.join(__dirname, dir);
}
const pages = {
  main: {
    entry: 'src/main.ts',
    template: 'src/index.html',
    filename: 'index.html'
  }
};

//配置end
module.exports = {
  publicPath: "./",
  //禁用eslint
  lintOnSave: false,
  productionSourceMap: false,
  pages: {
    main: {
      entry: 'src/main.ts',
      template: 'src/index.html',
      filename: 'index.html'
    }
  },
  devServer: {
    index: 'index.html', //默认启动serve 打开index页面
    open: process.platform === 'darwin',
    host: '', // 127.0.0.1
    port: 6700,
    https: false,
    hotOnly: false,
    proxy: null, // 设置代理
    before: app => { }
  },

  // css相关配置
  css: {
    extract: true,
    sourceMap: false,
    loaderOptions: {
      less: {
        javascriptEnabled: true
      },
      stylus: {
        'resolve url': true,
        'import': []
      }
    },
    modules: false
  },

  // 是否为 Babel 或 TypeScript 使用 thread-loader。该选项在系统的 CPU 有多于一个内核时自动启用，仅作用于生产构建。
  parallel: require('os').cpus().length > 1,

  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src'));
  },

  pluginOptions: {
    i18n: {
      locale: 'ch',             // The locale of project localization
      fallbackLocale: 'en',     // The fallback locale of project localization
      localeDir: 'locales',     // The directory where store localization messages of project
      enableInSFC: false        // Enable locale messages in Single file components
    }
  }
}
